home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / IconView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.3 KB  |  74 lines

  1. package javax.swing.text;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.Rectangle;
  5. import java.awt.Shape;
  6. import javax.swing.Icon;
  7. import javax.swing.text.Position.Bias;
  8.  
  9. public class IconView extends View {
  10.    // $FF: renamed from: c javax.swing.Icon
  11.    private Icon field_0;
  12.  
  13.    public IconView(Element var1) {
  14.       super(var1);
  15.       AttributeSet var2 = var1.getAttributes();
  16.       this.field_0 = StyleConstants.getIcon(var2);
  17.    }
  18.  
  19.    public float getAlignment(int var1) {
  20.       switch (var1) {
  21.          case 1:
  22.             return 1.0F;
  23.          default:
  24.             return super.getAlignment(var1);
  25.       }
  26.    }
  27.  
  28.    public float getPreferredSpan(int var1) {
  29.       switch (var1) {
  30.          case 0:
  31.             return (float)this.field_0.getIconWidth();
  32.          case 1:
  33.             return (float)this.field_0.getIconHeight();
  34.          default:
  35.             throw new IllegalArgumentException("Invalid axis: " + var1);
  36.       }
  37.    }
  38.  
  39.    public Shape modelToView(int var1, Shape var2, Position.Bias var3) throws BadLocationException {
  40.       int var4 = ((View)this).getStartOffset();
  41.       int var5 = ((View)this).getEndOffset();
  42.       if (var1 >= var4 && var1 <= var5) {
  43.          Rectangle var6 = var2.getBounds();
  44.          if (var1 == var5) {
  45.             var6.x += var6.width;
  46.          }
  47.  
  48.          var6.width = 0;
  49.          return var6;
  50.       } else {
  51.          throw new BadLocationException(var1 + " not in range " + var4 + "," + var5, var1);
  52.       }
  53.    }
  54.  
  55.    public void paint(Graphics var1, Shape var2) {
  56.       Rectangle var3 = var2.getBounds();
  57.       this.field_0.paintIcon(((View)this).getContainer(), var1, var3.x, var3.y);
  58.    }
  59.  
  60.    public void setSize(float var1, float var2) {
  61.    }
  62.  
  63.    public int viewToModel(float var1, float var2, Shape var3, Position.Bias[] var4) {
  64.       Rectangle var5 = (Rectangle)var3;
  65.       if (var1 < (float)(var5.x + var5.width / 2)) {
  66.          var4[0] = Bias.Forward;
  67.          return ((View)this).getStartOffset();
  68.       } else {
  69.          var4[0] = Bias.Backward;
  70.          return ((View)this).getEndOffset();
  71.       }
  72.    }
  73. }
  74.